export default (url) => {
  const crud = window.$crud(url);

  const getColNameList = (code) =>
    window.$axios({
      url: `${url}/${code}/colnames`,
      method: "get",
    });

  const getDataList = (code) =>
    window.$axios({
      url: `${url}/${code}/list`,
      method: "get",
    });

  const getDataListByParamter = (code, param) =>
    window.$axios({
      url: `${url}/${code}/listbyparam`,
      method: "get",
      params: { param },
    });

  const getDataPage = (code, pagination) =>
    window.$axios({
      url: `${url}/${code}/page`,
      method: "get",
      params: pagination,
    });

  const request = (url, method, params) =>
    window.$axios({
      url,
      method,
      params,
      data: params,
    });

  const apiData = (url, method, params) =>
    window.$axios({
      url,
      method,
      data: params,
    });

  const apiParams = (url, method, params) =>
    window.$axios({
      url,
      method,
      params,
    });

  return {
    ...crud,
    apiData,
    apiParams,
    getColNameList,
    getDataList,
    getDataListByParamter,
    getDataPage,
    request,
  };
};
